

package lesson3.slides.lang;


public class Behavior implements Runnable {
    public void run() {
        for (int i = 0; i < 1000; i++) {
            System.out.println("Thread " 
              + Thread.currentThread().getName() 
              + " counter is " + i);
        }
    }
    public static void main(String[] args) {
        System.out.println("The main thread has a name of "+Thread.currentThread().getName());
        Runnable r = new Behavior();
        Thread t1 = new Thread(r);
        t1.setName("My thread 1");
        Thread t2 = new Thread(r);
        t2.setName("My thread 2");
        t1.start();
        t2.start();
        System.out.println("Last statement of main");
    }
}
